package com.itheima.collection.set;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @author Anomaly
 * @date 2023/1/20 12:46
 */
public class SetDemo {
    public static void main(String[] args) {
        Set<String> strings = new HashSet<>();
        System.out.println(strings.add("java"));
        strings.add("python");
        strings.add("c++");
        strings.add("ruby");
        System.out.println(strings.add("java"));
        strings.add("perl");
        strings.add("spring");
        System.out.println("=========================");
        System.out.println(strings);
        System.out.println("=========================");
        for (String string : strings) {
            System.out.println(string);
        }
        System.out.println("=========================LinkedHashSet");
        Set<String> strings2 = new LinkedHashSet<>();
        System.out.println(strings2.add("java"));
        strings2.add("python");
        strings2.add("c++");
        strings2.add("ruby");
        System.out.println(strings2.add("java"));
        strings2.add("perl");
        strings2.add("spring");
        System.out.println(strings2);
    }
}
